Skip to content

fix: enforce spec compliance in GitHub module#178

Merged
maystudios merged 1 commit intomainfrom
worktree-agent-a9ba34bf
Mar 25, 2026
Merged

fix: enforce spec compliance in GitHub module#178
maystudios merged 1 commit intomainfrom
worktree-agent-a9ba34bf

Conversation

@maystudios
Copy link
Copy Markdown
Owner

Summary

  • projects.ts: Replace console.warn with proper ok: false error return when GraphQL mutation to add missing Status field options fails, so callers handle the failure instead of silently continuing
  • discussions.ts: Add cursor-based auto-pagination to listDiscussions using pageInfo { hasNextPage endCursor }, fetching all pages instead of only the first
  • comments.ts: Add runtime validation of the type field in parseCommentMeta against a known set of valid types, returning null for unrecognized types instead of blindly casting
  • types.ts: Extend MaxsimCommentMeta.type union with phase-complete and checkpoint variants

Test plan

  • New test: ensureProjectBoard returns ok: false when GraphQL mutation fails
  • New test: listDiscussions paginates through multiple pages and returns all results
  • New test: parseCommentMeta returns null for invalid type strings
  • All 532 existing tests pass
  • Build succeeds
  • Lint clean on changed files

🤖 Generated with Claude Code

… comments)

- projects.ts: replace console.warn with proper error return on failed
  Status field mutation, ensuring callers see ok:false instead of silent
  continuation
- discussions.ts: add cursor-based auto-pagination to listDiscussions so
  all pages are fetched instead of only the first
- comments.ts: add runtime validation of comment type field against the
  known set, rejecting unrecognized types with null instead of blindly
  casting via `as`
- types.ts: extend MaxsimCommentMeta type union with phase-complete and
  checkpoint variants
- Update all corresponding unit tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 25, 2026 12:50
@maystudios maystudios merged commit 16fc6fd into main Mar 25, 2026
3 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 5.13.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens GitHub-module spec compliance by turning previously “best-effort” behaviors into explicit, handleable results, and by ensuring GitHub Discussions listing returns complete data via pagination.

Changes:

  • ensureProjectBoard: return ok: false when the GraphQL mutation to add missing Status options fails (instead of logging a warning and continuing).
  • listDiscussions: add cursor-based auto-pagination using pageInfo { hasNextPage endCursor } to fetch all pages.
  • parseCommentMeta / types: add runtime validation for comment type and extend the allowed MaxsimCommentMeta.type variants.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/cli/src/github/projects.ts Converts a failed Status-option GraphQL update into a structured error result.
packages/cli/src/github/discussions.ts Implements cursor-based pagination for discussions listing.
packages/cli/src/github/comments.ts Adds runtime validation for comment metadata type.
packages/cli/src/github/types.ts Extends MaxsimCommentMeta.type union with phase-complete and checkpoint.
packages/cli/tests/unit/github-projects.test.ts Adds coverage for GraphQL mutation failure path in ensureProjectBoard.
packages/cli/tests/unit/github-discussions.test.ts Adds coverage ensuring listDiscussions paginates and aggregates results.
packages/cli/tests/unit/comments.test.ts Adds coverage for rejecting invalid comment type values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return {
ok: false,
error: `Failed to add missing Status options (${missingColumns.map((c) => c.name).join(', ')}): ${updateResult.error}`,
code: 'UNKNOWN',
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ensureProjectBoard hard-codes code: 'UNKNOWN' when the GraphQL update fails, which loses the more specific updateResult.code classification from ghExec (e.g., FORBIDDEN/RATE_LIMITED). Propagate updateResult.code instead so callers can handle failures consistently.

Suggested change
code: 'UNKNOWN',
code: updateResult.code ?? 'UNKNOWN',

Copilot uses AI. Check for mistakes.
Comment on lines +231 to +232
hasNextPage = pageInfo?.hasNextPage ?? false;
endCursor = pageInfo?.endCursor ?? null;
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pagination loop can become infinite if GitHub returns hasNextPage: true but endCursor is null/empty (then after is never sent and the same page is requested repeatedly). Add a guard that returns an error (or breaks) when hasNextPage is true but endCursor is missing.

Suggested change
hasNextPage = pageInfo?.hasNextPage ?? false;
endCursor = pageInfo?.endCursor ?? null;
const nextHasNextPage = pageInfo?.hasNextPage ?? false;
const nextEndCursor = pageInfo?.endCursor ?? null;
// Guard against a potential infinite loop if GitHub reports hasNextPage
// but does not provide an endCursor for the next page.
if (nextHasNextPage && !nextEndCursor) {
break;
}
hasNextPage = nextHasNextPage;
endCursor = nextEndCursor;

Copilot uses AI. Check for mistakes.
};
}

const VALID_COMMENT_TYPES = new Set(['plan', 'research', 'context', 'progress', 'verification', 'summary', 'error', 'escalation', 'handoff', 'user-intent', 'phase-complete', 'checkpoint'] as const);
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VALID_COMMENT_TYPES duplicates the MaxsimCommentMeta['type'] union in types.ts, which can drift over time. Consider defining a single exported const array of comment types and deriving both the union type and the runtime Set/type-guard from it to keep them in sync.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants